Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added documentation for the new absolute_url() and relative_path() Twig functions #4805

Merged
merged 1 commit into from
Jan 25, 2015

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Jan 10, 2015

Q A
Doc fix? no
New docs? symfony/symfony#13264
Applies to 2.7
Fixed tickets n/a

fabpot added a commit to symfony/symfony that referenced this pull request Jan 10, 2015
This PR was merged into the 2.7 branch.

Discussion
----------

URL manipulations as a Twig extension

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | symfony/symfony-docs#4805

While working on the new asset component, I realized that the "absolute URL" feature was misplaced and would benefit from being exposed as a Twig function (composition is always a good thing). Then, I wondered if having a Twig function to generate a relative path (like done by the Routing component would also make sense). And here is the corresponding PR.

```jinja
{# generate an absolute URL for the given absolute path #}
{{ absolute_url('/me.png') }}

{# generate a relative path for the given absolute path (based on the current Request) #}
{{ relative_path('/foo/me.png') }}

{# compose as you see fit #}
{{ absolute_url(asset('me.png')) }}
```

As you can see, we require an absolute path for both functions (and we even add the leading slash if it is omitted), not sure if we want to do otherwise.

ping @Tobion

Commits
-------

0ec852d added a relative_path Twig function
ee27ed8 added an absolute_url() Twig function
fabpot added a commit to symfony/twig-bridge that referenced this pull request Jan 10, 2015
This PR was merged into the 2.7 branch.

Discussion
----------

URL manipulations as a Twig extension

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | symfony/symfony-docs#4805

While working on the new asset component, I realized that the "absolute URL" feature was misplaced and would benefit from being exposed as a Twig function (composition is always a good thing). Then, I wondered if having a Twig function to generate a relative path (like done by the Routing component would also make sense). And here is the corresponding PR.

```jinja
{# generate an absolute URL for the given absolute path #}
{{ absolute_url('/me.png') }}

{# generate a relative path for the given absolute path (based on the current Request) #}
{{ relative_path('/foo/me.png') }}

{# compose as you see fit #}
{{ absolute_url(asset('me.png')) }}
```

As you can see, we require an absolute path for both functions (and we even add the leading slash if it is omitted), not sure if we want to do otherwise.

ping @Tobion

Commits
-------

0ec852d added a relative_path Twig function
ee27ed8 added an absolute_url() Twig function
fabpot added a commit to symfony/twig-bundle that referenced this pull request Jan 10, 2015
This PR was merged into the 2.7 branch.

Discussion
----------

URL manipulations as a Twig extension

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | symfony/symfony-docs#4805

While working on the new asset component, I realized that the "absolute URL" feature was misplaced and would benefit from being exposed as a Twig function (composition is always a good thing). Then, I wondered if having a Twig function to generate a relative path (like done by the Routing component would also make sense). And here is the corresponding PR.

```jinja
{# generate an absolute URL for the given absolute path #}
{{ absolute_url('/me.png') }}

{# generate a relative path for the given absolute path (based on the current Request) #}
{{ relative_path('/foo/me.png') }}

{# compose as you see fit #}
{{ absolute_url(asset('me.png')) }}
```

As you can see, we require an absolute path for both functions (and we even add the leading slash if it is omitted), not sure if we want to do otherwise.

ping @Tobion

Commits
-------

0ec852d added a relative_path Twig function
ee27ed8 added an absolute_url() Twig function
fabpot added a commit to symfony/http-foundation that referenced this pull request Jan 10, 2015
This PR was merged into the 2.7 branch.

Discussion
----------

URL manipulations as a Twig extension

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | symfony/symfony-docs#4805

While working on the new asset component, I realized that the "absolute URL" feature was misplaced and would benefit from being exposed as a Twig function (composition is always a good thing). Then, I wondered if having a Twig function to generate a relative path (like done by the Routing component would also make sense). And here is the corresponding PR.

```jinja
{# generate an absolute URL for the given absolute path #}
{{ absolute_url('/me.png') }}

{# generate a relative path for the given absolute path (based on the current Request) #}
{{ relative_path('/foo/me.png') }}

{# compose as you see fit #}
{{ absolute_url(asset('me.png')) }}
```

As you can see, we require an absolute path for both functions (and we even add the leading slash if it is omitted), not sure if we want to do otherwise.

ping @Tobion

Commits
-------

0ec852d added a relative_path Twig function
ee27ed8 added an absolute_url() Twig function
@xabbuh
Copy link
Member

xabbuh commented Jan 10, 2015

👍

1 similar comment
@wouterj
Copy link
Member

wouterj commented Jan 16, 2015

👍


Returns a relative path for the given absolute path (based on the current
request path). For instance, if the current path is
``/article/news/welcome.html``, the relative path for path
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line reads a bit strange to me:

the relative path for path ``/article/image.png`` is ``../images.png``.

What about using this instead:

the relative path for ``/article/image.png`` path is ``../images.png``.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the second "path" completely: "the relative path for /article/image.png is ../images.png"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @fabpot

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed now

@wouterj
Copy link
Member

wouterj commented Jan 23, 2015

👍 again, it's ready!

@weaverryan weaverryan merged commit e4d22f0 into symfony:master Jan 25, 2015
weaverryan added a commit that referenced this pull request Jan 25, 2015
…tive_path() Twig functions (fabpot)

This PR was merged into the master branch.

Discussion
----------

added documentation for the new absolute_url() and relative_path() Twig functions

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | symfony/symfony#13264
| Applies to    | 2.7
| Fixed tickets | n/a

Commits
-------

e4d22f0 added documentation for the new absolute_url() and relative_path() Twig functions
@weaverryan
Copy link
Member

Thanks! FYI - I merged this too quickly into master, but cherry-picked back to 2.7 at sha: 8fe9069

weaverryan added a commit that referenced this pull request Jan 25, 2015
weaverryan added a commit that referenced this pull request Jan 25, 2015
* 2.7:
  [#4805] Adding versionadded
  added documentation for the new absolute_url() and relative_path() Twig functions
  Remove 'acme'
  Update routing.rst
  [#4786] Adding a few versionadded's for the changed method name
  Replaced setDefaultOptions by the new configureOptions method
  Typo
  Update introduction.rst
  [Book][Translation] Added tip for routing params
  [varnish] be more precise about version differences
  Remove trailing whitespace
  [BestPractices] fix minor typo
  Remove horizontal scrollbar
  [Components][Debug] fix DebugClassLoader namespace
  Update override.rst
  Update override.rst
  [Book][Security] add back old anchors
  [Cookbook][Security] Hint about createToken can return null
  Add version added note for the debug:event-dispatcher command

Conflicts:
	reference/twig_reference.rst
wouterj added a commit that referenced this pull request Feb 14, 2015
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #4977).

Discussion
----------

Unnecessary comma

Commits
-------

8a2f0ba Wrong comma
81e8c13 Merge branch '2.7'
ef39a01 Remove diff
8d56ad7 Merge branch '2.7'
6fd286b Added January changelog
ad97700 Merge branch '2.7'
c0f9f67 Merge branch '2.7'
87eb36c Merge branch '2.7'
714f630 Merge branch '2.7'
99e2996 Merge branch '2.7'
c33b371 Merge branch '2.7'
6c498d4 feature #4805 added documentation for the new absolute_url() and relative_path() Twig functions (fabpot)
e4d22f0 added documentation for the new absolute_url() and relative_path() Twig functions
907ee0d Merge branch '2.7'
a17bdd7 Merge branch '2.7'
ca3b4c8 feature #4753 bump Symfony requirements to PHP 5.5 (xabbuh)
9919bca Revert "Fixed markup"
c859790 Fixed markup
032a6b4 Merge branch '2.7'
92b10b1 bug #4758 [Components][Yaml] don't describe removed usage of Yaml::parse() (xabbuh)
42d2b15 Merge branch '2.7'
6f9832d Merge branch '2.7'
d33b78b don't describe removed usage of Yaml::parse()
bcab77b bump Symfony requirements to PHP 5.5
6ef6a04 Merge branch '2.7'
fcfea43 Merge branch '2.7'
353995e Merge branch '2.7'
27296ad Merge branch '2.7'
56db7af Merge branch '2.7'
9e5fc6c Merge branch '2.7'
cb6f846 Merge branch '2.7'
8131844 Merge branch '2.7'
2fcebc1 Merge branch '2.7'
07aa543 Merge branch '2.7'
4056218 Merge branch '2.7'
0906e0c Merge branch '2.7'
e539bd1 Merge branch '2.7'
2d1c336 Merge branch '2.7'
d30dc9e Merge remote-tracking branch 'origin/master'
3454883 Merge branch '2.7'
f0ac8bb Merge branch '2.7'
d921dcd Merge branch '2.7'
486baf8 Merge branch '2.7'
8099ac1 Merge branch '2.7'
6b73990 Merge branch '2.7'
0fb81cc Merge branch '2.7'
d969e8b Merge branch '2.7'
f24b645 Merge branch '2.7'
d6ce29f Merge branch '2.7'
51224e9 Merge branch '2.7'
0c92fab Merge branch '2.7'
0d5cb0d Merge branch '2.7'
3329bd2 feature #4424 [#4243] Tweaks to the new var-dumper component (weaverryan, nicolas-grekas)
9caea6f feature #4336 [Form] Add entity manager instance support for em option (egeloen)
1a29f24 typos in the var-dumper component
09a6fd7 [Form] Add entity manager instance support for em option
265604b [#4243] Tweaks to the new var-dumper component
javiereguiluz pushed a commit to javiereguiluz/symfony-docs that referenced this pull request Jun 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants